import { createReadStream, readFileSync } from "fs";

export async function postUploadZip(url: string, data: {
    env: 'test'|'release',
    filePath: string
    fileName: string
}) {
    const formData = new FormData();
    formData.append('key', '7H8CyjhL4R');
    formData.append('path', data.env);
    // 将filePath转为Blob
    const file = readFileSync(data.filePath);
    const blob = new Blob([file], { type: 'application/octet-stream' });
    formData.append('file', blob, data.fileName);
    const response = await fetch(url, {
        method: 'POST',
        body: formData
    });
    return response.json();
}
